<% include header %>

<form action="/add" method="post">
    物品名称: <br>
    <input type="text" name="title" required> <br> <br>
    物品价格：<br />
  	<input type="text" name="price" required=""/><br />  <br />
    物品分类: <br>
    <input type="text" name="tag" required><br> <br>
  月销售量: <br />
  	<input type="text" name="monNum" required=/> <br /><br />
     地址: <br />
     <input type="text" name="address" required/> <br /><br />
   促销: <br />
   <input type="text"name="manjian" required="" /><br /><br />
    上传物品图片：<br />
    <input type="file" name="photo" required="" /><br /><br />
  
    <button type="submit">添加</button>
</form>


<% include footer %>
<script>
	
	$('form').submit(function(ev){
		ev.preventDefault();
		var data = new FormData(this);
		$.post({
			url:'/add',
			data:data,
			contentType:false, 
			processData:false,  
			success:function(resData){
				if(resData.error==0){
					alert(resData.message);
					location.href = '/';
				}
				else{
					alert(resData.message);
					location.reload();
				}
			}
		})
	})
</script>